import pygame,math,sys,random

class HealthBar():
    def __init__(self, position):
        self.surfaces = []
        self.surfaces += [pygame.image.load("rsc/Zombies/Zombie with Health/zombieHealth50%.png")]
        self.surfaces += [pygame.image.load("rsc/Zombies/Zombie with Health/ZombieHealth60%.png")]
        self.surfaces += [pygame.image.load("rsc/Zombies/Zombie with Health/Zombiehealth70%.png")]
        self.surfaces += [pygame.image.load("rsc/Zombies/Zombie with Health/Zombiehealth80%.png")]
        self.surfaces += [pygame.image.load("rsc/Zombies/Zombie with Health/Zombiehealth90%.png")]
        self.surfaces += [pygame.image.load("rsc/Zombies/Zombie with Health/Zombiehealth100%.png")]
        self.maxFrame = len(self.surfaces)-1
        self.frame = self.maxFrame
        self.surface = self.surfaces[self.frame]
        self.rect = self.surface.get_rect()
        self.rect.center = position
       
    def  __str__(self):
        return str(self.rect.center) + str(self.speed) + str(self.living)
     
    def helth_bare(self):
        pass
            
    def update(self, life, maxLife):
        percentLife = float(life)/float(maxHealth)
        if percentLife > .75:
            self.frame = 5
        elif percentLife > .50:
            self.frame = 4
        elif percentLife > .25:
            self.frame = 3
        elif percentLife > .01:
            self.frame = 2
        elif percentLife > 0:
            self.frame = 1
        else:
            self.frame = 0
        self.surface = self.surfaces[self.frame]